home *** CD-ROM | disk | FTP | other *** search
- package asp.netobjects.nfx.ui;
-
- import com.sun.java.swing.border.AbstractBorder;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Insets;
-
- public class EtchedTopBorder extends AbstractBorder {
- public static final int RAISED = 0;
- public static final int LOWERED = 1;
- protected int etchType;
- protected Color highlight;
- protected Color shadow;
-
- public EtchedTopBorder() {
- this(1);
- }
-
- public EtchedTopBorder(int etchType) {
- this(etchType, (Color)null, (Color)null);
- }
-
- public EtchedTopBorder(Color highlight, Color shadow) {
- this(1, highlight, shadow);
- }
-
- public EtchedTopBorder(int etchType, Color highlight, Color shadow) {
- this.etchType = etchType;
- this.highlight = highlight;
- this.shadow = shadow;
- }
-
- public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
- g.translate(x, y);
- g.setColor(this.etchType == 1 ? this.getShadowColor(c) : this.getHighlightColor(c));
- g.drawLine(0, 0, width - 2, 0);
- g.setColor(this.etchType == 1 ? this.getHighlightColor(c) : this.getShadowColor(c));
- g.drawLine(1, 1, width - 3, 1);
- g.translate(-x, -y);
- }
-
- public Insets getBorderInsets(Component c) {
- return new Insets(0, 2, 0, 0);
- }
-
- public boolean isBorderOpaque() {
- return true;
- }
-
- public int getEtchType() {
- return this.etchType;
- }
-
- public Color getHighlightColor(Component c) {
- return this.highlight != null ? this.highlight : c.getBackground().brighter();
- }
-
- public Color getShadowColor(Component c) {
- return this.shadow != null ? this.shadow : c.getBackground().darker();
- }
- }
-